function calculateDealer4() {
    // 终端试剂销售额
    document.getElementById('terminalSalesAmount').value = document.getElementById('reagentSale_all_dealerCalcEsti').value + '万元';
    // 仪器投放成本
    document.getElementById('instInstallCost').value =  parseNum(document.getElementById('instCostAllNow').value) + '万元';
    // 测算利润
    document.getElementById('calcProfit').value =  document.getElementById('yearIncome_all_dealerCalcEsti_Show').value + '万元';
    // 本单应回收净利润
    document.getElementById('netProfit').value =  document.getElementById('bottomIncome_all_dealerYieldEsti').value + '万元';
    // 现项目子公司收益率
    document.getElementById('dealerProfitPerNow').value =  document.getElementById('incomeRate_first_dealerYieldNow').value;
    // 含预计项目子公司收益率
    document.getElementById('dealerProfitPerEsti').value =  document.getElementById('incomeRate_first_dealerYieldEsti').value;
    // 现项目子公司回收期
    document.getElementById('dealerRecruitNow').value =  document.getElementById('recruit_1_dealerCalcNow').value;
    // 含预计项目子公司回收期
    document.getElementById('dealerRecruitEsti').value =  document.getElementById('recruit_1_dealerCalcEsti').value;
    // 现项目子公司净利润
    document.getElementById('dealerNetProfitNow').value = document.getElementById('yearIncome_all_dealerCalcNow_Show').value + '万元';
    // 含预计项目子公司净利润
    document.getElementById('dealerNetProfitEsti').value = document.getElementById('yearIncome_all_dealerCalcEsti_Show').value + '万元';


    

  

}

function calculateDealer3() {
    // 回收期
    var drn;
    var dre;
    // 仪器成本
    var instCostN = parseFloatExtension(document.getElementById('instCostAllNow').value);
    var instCostE = parseFloatExtension(document.getElementById('instCostAllEsti').value);

    // 当年利润
    var yearIncomeN = parseFloatExtension(document.getElementById('yearIncome_all_dealerCalcNow').value);
    var yearIncomeE = parseFloatExtension(document.getElementById('yearIncome_all_dealerCalcEsti').value);
    var mons = 60 ;

    if (instCostN + yearIncomeN == 0) {
        drn = '-';
    } else if (Math.floor(instCostN / (instCostN + yearIncomeN) * mons / 12) < 0) {
        drn = Math.ceil((instCostN / (instCostN + yearIncomeN) * mons - Math.floor(instCostN / (instCostN + yearIncomeN) * mons)) * 12) + '个月';
    } else {
        drn = Math.floor(instCostN / (instCostN + yearIncomeN) * mons / 12) + '年' + Math.ceil((instCostN / (instCostN + yearIncomeN) * mons - Math.floor(instCostN / (instCostN + yearIncomeN) * mons/12)* 12)) + '个月';
    }
    if (instCostE + yearIncomeE == 0) {
        dre = '-';
    } else if (Math.floor(instCostE / (instCostE + yearIncomeE) * mons / 12) < 0) {
        dre = Math.ceil((instCostE / (instCostE + yearIncomeE) * mons - Math.floor(instCostE / (instCostE + yearIncomeE) * mons)) * 12) + '个月';
    } else {
        dre = Math.floor(instCostE / (instCostE + yearIncomeE) * mons / 12) + '年' + Math.ceil((instCostE / (instCostE + yearIncomeE) * mons - Math.floor(instCostE / (instCostE + yearIncomeE) * mons/12)* 12)) + '个月';
    }
    document.getElementById('recruit_1_dealerCalcNow').value = drn;
    document.getElementById('recruit_1_dealerCalcEsti').value = dre;
    // 收益率
   /* var irdnArray = new Array();
    var irdeArray = new Array();
    irdnArray.push(parseFloatExtension(document.getElementById('yearIncome_first_dealerYieldNow').value));
    irdeArray.push(parseFloatExtension(document.getElementById('yearIncome_first_dealerYieldEsti').value));
    for (var m = 1; m <= yearCnt; m++) {
        irdnArray.push(parseFloatExtension(document.getElementById('yearIncome_' + m + '_dealerYieldNow').value));
        irdeArray.push(parseFloatExtension(document.getElementById('yearIncome_' + m + '_dealerYieldEsti').value));
    }
    var irdn = IRR(irdnArray);
    var irde = IRR(irdeArray);
    document.getElementById('incomeRate_first_dealerYieldNow').value = parseNum(irdn * 100, 2) + '%';
    document.getElementById('incomeRate_first_dealerYieldEsti').value = parseNum(irde * 100, 2) + '%';
     */
     var irdnArray = new Array();
    var irdeArray = new Array();

    ///5年收益率
    var irdnArray5 = new Array();
    var irdeArray5 = new Array();

    irdnArray.push(parseFloatExtension(document.getElementById('yearIncome_first_dealerYieldNow').value));
    irdeArray.push(parseFloatExtension(document.getElementById('yearIncome_first_dealerYieldEsti').value));

    irdnArray5.push(parseFloatExtension(document.getElementById('yearIncome_first_dealerYieldNow').value));
    irdeArray5.push(parseFloatExtension(document.getElementById('yearIncome_first_dealerYieldEsti').value));
    for (var m = 1; m <= yearCnt; m++) {

        irdnArray.push(parseFloatExtension(document.getElementById('yearIncome_' + m + '_dealerYieldNow').value));
        irdeArray.push(parseFloatExtension(document.getElementById('yearIncome_' + m + '_dealerYieldEsti').value));
        if(yearCnt > 5 && m <=5) {
            irdnArray5.push(parseFloatExtension(document.getElementById('yearIncome_' + m + '_dealerYieldNow').value));
            irdeArray5.push(parseFloatExtension(document.getElementById('yearIncome_' + m + '_dealerYieldEsti').value));   
        }
        

    }
    var irdn = IRR(irdnArray);
    var irde = IRR(irdeArray);

    var irdn5 = IRR(irdnArray5);
    var irde5 = IRR(irdeArray5);

    if(yearCnt > 5){
        document.getElementById('incomeRate_first_dealerYieldNow_5').value = parseNum(irdn5 * 100, 2) + '%';
        document.getElementById('incomeRate_first_dealerYieldEsti_5').value = parseNum(irde5 * 100, 2) + '%';

    }

    document.getElementById('incomeRate_first_dealerYieldNow').value = parseNum(irdn * 100, 2) + '%';
    document.getElementById('incomeRate_first_dealerYieldEsti').value = parseNum(irde * 100, 2) + '%';
    //收益率
    var companyYieldNowHidden = document.getElementById('page:form:companyYieldNowHidden');
    var companyYieldEstiHidden = document.getElementById('page:form:companyYieldEstiHidden');
  
    var companyYieldNowHiddenJL = document.getElementById('page:form:companyYieldNowHiddenJL');
    var companyYieldEstiHiddenJL = document.getElementById('page:form:companyYieldEstiHiddenJL'); 

    if(companyYieldNowHidden != null )companyYieldNowHidden.value = parseNum(irdn * 100, 2);
    if(companyYieldEstiHidden != null )companyYieldEstiHidden.value = parseNum(irde * 100, 2);

    if(companyYieldNowHiddenJL != null )companyYieldNowHiddenJL.value = parseNum(irdn * 100, 2);
    if(companyYieldEstiHiddenJL != null )companyYieldEstiHiddenJL.value = parseNum(irde * 100, 2);
   


}

function calculateDealer2() {
    // 应回收现值合计
    var rdna = 0;
    var rdea = 0;
    // 每年最低要求利润合计
    var bidna = 0;
    var bidea = 0;

    // 年循环
    for (var m = 1; m <= yearCnt; m++) {
        // 比例=折现值/折现值合计
        var pdn = document.getElementById('liquidityV_' + m + '_dealerYieldNow').value / (document.getElementById('liquidityV_sum_dealerYieldNow').value / 100);
        var pde = document.getElementById('liquidityV_' + m + '_dealerYieldEsti').value / (document.getElementById('liquidityV_sum_dealerYieldEsti').value / 100);
        document.getElementById('percent_' + m + '_dealerYieldNow').value = parseNum(pdn) + '%';
        document.getElementById('percent_' + m + '_dealerYieldEsti').value = parseNum(pde) + '%';
        // 应回收现值=折现值:初始投入*比例
        var rdn = -document.getElementById('liquidityV_first_dealerYieldNow').value * pdn / 100;
        var rde = -document.getElementById('liquidityV_first_dealerYieldEsti').value * pde / 100;
        document.getElementById('return_' + m + '_dealerYieldNow').value = parseNum(rdn);
        document.getElementById('return_' + m + '_dealerYieldEsti').value = parseNum(rde);
        rdna += parseNum(rdn);
        rdea += parseNum(rde);
        // 每年最低要求利润=应回收现值/折现率
        var bidn = rdn / (document.getElementById('page:form:dealerYieldNow:' + (m - 1) + ':liquidityP_first_dealerYieldNow').innerText / 100);
        var bide = rde / (document.getElementById('page:form:dealerYieldEsti:' + (m - 1) + ':liquidityP_first_dealerYieldEsti').innerText / 100);
        document.getElementById('bottomIncome_' + m + '_dealerYieldNow').value = parseNum(bidn);
        document.getElementById('bottomIncome_' + m + '_dealerYieldEsti').value = parseNum(bide);
        bidna += parseNum(bidn);
        bidea += parseNum(bide);
    }
    // 应回收现值
    document.getElementById('return_all_dealerYieldNow').value = rdna;
    document.getElementById('return_all_dealerYieldEsti').value = rdea;
    // 每年最低要求利润
    document.getElementById('bottomIncome_all_dealerYieldNow').value = parseInt(document.getElementById('bottomIncome_first_dealerYieldNow').value) + parseNum(bidna);
    document.getElementById('bottomIncome_all_dealerYieldEsti').value = parseInt(document.getElementById('bottomIncome_first_dealerYieldEsti').value) + parseNum(bidea);
}

function calculateDealer() {
    // 销售员及其主管看不到收益率栏
    if (cantSeeYield == 'true') return;

    // 试剂销售合计
    var stna = 0;
    var stea = 0;
    // 试剂成本合计
    var ctna = 0;
    var ctea = 0;
    // 毛利合计
    var rna = 0;
    var rea = 0;
    // 增值税合计
    var taxna = 0;
    var taxea = 0;
    // 费用合计
    var fna = 0;
    var fea = 0;
    // 维修成本合计
    var rcna = 0;
    var rcea = 0;
    // 业务费合计
    var bfna = 0;
    var bfea = 0;
    // 所得税合计
    var itna = 0;
    var itea = 0;
    // 试剂纯利合计
    var rina = 0;
    var riea = 0;
    // 当年利润合计
    var yina = 0;
    var yiea = 0;
    // 本单每年利润合计
    var tyina = 0;
    var tyiea = 0;
    // 折现值合计
    var lvna = 0;
    var lvea = 0;
    var dfin = 0;
    var dfie = 0;
    // 子公司是否生物制品简易增收
    var companyCanRepair = document.getElementById('page:form:CompanyCanRepair').checked;

    // 年循环
    for (var m = 1; m <= yearCnt; m++) {
        // 试剂销售
        var stn = 0;
        var ste = 0;
        // 子公司是否生物制品简易增收=false：销售额的合计/1.13/10000
        if (companyCanRepair == false) {
            stn = parseFloatExtension(document.getElementById('salesNumSumNow_real' + m).value / 1.13);
            ste = parseFloatExtension(document.getElementById('salesNumSumEsti_real' + m).value / 1.13);
        }
        // 子公司是否生物制品简易增收=true：每一行的销售额/税率的合计/10000
        else {
            for (var n = 0; n < dataCnt; n++) {
                if (document.getElementById('page:form:repeat1:' + n + ':productId').value == '') continue;

                var t = document.getElementById('page:form:repeat1:' + n + ':type').innerText.trim();
                // 隐藏字段：每一行的销售额/税率
                var a = parseFloatExtension(document.getElementById('st' + m + '_' + n).value);
                if (t == '现有') {
                    stn += a;
                }
                ste += a;
            }
        }
        document.getElementById('reagentSale_' + m + '_dealerCalcNow_Show').value = parseNum(stn / 10000);
        document.getElementById('reagentSale_' + m + '_dealerCalcEsti_Show').value = parseNum(ste / 10000);
        document.getElementById('reagentSale_' + m + '_dealerCalcNow').value = parseFloatExtension(stn / 10000);
        document.getElementById('reagentSale_' + m + '_dealerCalcEsti').value = parseFloatExtension(ste / 10000);
        stna += parseFloatExtension(stn / 10000);
        stea += parseFloatExtension(ste / 10000);
        
        // 试剂成本
        var ctn = 0;
        var cte = 0;
        for (var n = 0; n < dataCnt; n++) {
            if (document.getElementById('page:form:repeat1:' + n + ':productId').value == '') continue;

            var t = document.getElementById('page:form:repeat1:' + n + ':type').innerText.trim();
            // 隐藏字段：每一行的成本/税率
            var a = parseFloatExtension(document.getElementById('ct' + m + '_' + n).value);
            if (t == '现有') {
                ctn += a;
            }
            cte += a;
        }
        document.getElementById('reagentCost_' + m + '_dealerCalcNow_Show').value = parseNum(ctn / 10000);
        document.getElementById('reagentCost_' + m + '_dealerCalcEsti_Show').value = parseNum(cte / 10000);
        document.getElementById('reagentCost_' + m + '_dealerCalcNow').value = parseFloatExtension(ctn / 10000);
        document.getElementById('reagentCost_' + m + '_dealerCalcEsti').value = parseFloatExtension(cte / 10000);
        ctna += parseFloatExtension(ctn / 10000);
        ctea += parseFloatExtension(cte / 10000);

        // 毛利=试剂销售+其他收入-试剂成本
        var rn = parseFloatExtension(stn / 10000) + parseFloatExtension(document.getElementById('page:form:dealerCalcNow:' + (m - 1) + ':trpn' + m).value) - parseFloatExtension(ctn / 10000);
        var re = parseFloatExtension(ste / 10000) + parseFloatExtension(document.getElementById('page:form:dealerCalcEsti:' + (m - 1) + ':trpe' + m).value) - parseFloatExtension(cte / 10000);
        document.getElementById('rawIncome_' + m + '_dealerCalcNow').value = parseNum(rn);
        document.getElementById('rawIncome_' + m + '_dealerCalcEsti').value = parseNum(re);
        rna += rn;
        rea += re;

        // 增值税=(试剂销售+其他收入-试剂成本-仪器成本/1.13)*0.13
        var taxn = (parseFloatExtension(stn / 10000) + parseFloatExtension(document.getElementById('page:form:dealerCalcNow:' + (m - 1) + ':trpn' + m).value) - parseFloatExtension(ctn / 10000) - parseFloatExtension(document.getElementById('dppn' + m).value)/1.13) * 0.13;
        var taxe = (parseFloatExtension(ste / 10000) + parseFloatExtension(document.getElementById('page:form:dealerCalcEsti:' + (m - 1) + ':trpe' + m).value) - parseFloatExtension(cte / 10000) - parseFloatExtension(document.getElementById('dppe' + m).value)/1.13) * 0.13;
        document.getElementById('tax_' + m + '_dealerCalcNow').value = parseNum(taxn);
        document.getElementById('tax_' + m + '_dealerCalcEsti').value = parseNum(taxe);
        taxna += parseFloatExtension(taxn);
        taxea += parseFloatExtension(taxe);
        // 费用=销售额的合计 * 0.03 / 10000
        var fn = parseFloatExtension(document.getElementById('salesNumSumNow_real' + m).value) * 0.03 / 10000;
        var fe = parseFloatExtension(document.getElementById('salesNumSumEsti_real' + m).value) * 0.03 / 10000;
        document.getElementById('fee_' + m + '_dealerCalcNow').value = parseNum(fn);
        document.getElementById('fee_' + m + '_dealerCalcEsti').value = parseNum(fe);
        fna += parseFloatExtension(fn);
        fea += parseFloatExtension(fe);
        // 维修成本：第一年=0，之后每年=0
        // TODO xudan 这里的Excel逻辑有点奇怪
        // 经销商利润结果的维修成本有值的话，子公司利润结果的维修成本就为0，但是经销商利润结果的维修成本是公式=仪器维修成本的合计
        // 只要有仪器，那经销商利润结果的维修成本必然有值，那子公司利润结果的维修成本必然为0
        var rcn = 0;
        var rce = 0;
        ///维修总成本
        var  rcs =document.getElementById('instrumentRepairCostSum_show').value 
        if (m == 1) {
            document.getElementById('repairCost_' + m + '_dealerCalcNow_Show').value = 0;
            document.getElementById('repairCost_' + m + '_dealerCalcEsti_Show').value = 0;
            document.getElementById('repairCost_' + m + '_dealerCalcNow').value = 0;
            document.getElementById('repairCost_' + m + '_dealerCalcEsti').value = 0;
        } else {
            if (coopDealer == '' ) {
               document.getElementById('repairCost_' + m + '_dealerCalcNow_Show').value = parseNum(rcs / 10000);
                document.getElementById('repairCost_' + m + '_dealerCalcEsti_Show').value = parseNum(rcs / 10000);
                document.getElementById('repairCost_' + m + '_dealerCalcNow').value = parseFloatExtension(rcs / 10000);
                document.getElementById('repairCost_' + m + '_dealerCalcEsti').value = parseFloatExtension(rcs / 10000);  
            }else{
                 document.getElementById('repairCost_' + m + '_dealerCalcNow_Show').value = 0;
                document.getElementById('repairCost_' + m + '_dealerCalcEsti_Show').value = 0;
                document.getElementById('repairCost_' + m + '_dealerCalcNow').value = 0;
                document.getElementById('repairCost_' + m + '_dealerCalcEsti').value = 0 ;
            }
            
        }
        rcn = document.getElementById('repairCost_' + m + '_dealerCalcNow').value;
        rce = document.getElementById('repairCost_' + m + '_dealerCalcEsti').value;
        rcna += parseFloatExtension(rcn);
        rcea += parseFloatExtension(rce);
        // 业务费
        var bfn = 0;
        var bfe = 0;
        for (var n = 0; n < dataCnt; n++) {
            if (document.getElementById('page:form:repeat1:' + n + ':productId').value == '') continue;

            var t = document.getElementById('page:form:repeat1:' + n + ':type').innerText.trim();
            // 隐藏字段：每一行的销售额*销售费用比例
            var a = parseFloatExtension(document.getElementById('sarp' + m + '_' + n).value);
            if (t == '现有') {
                bfn += a;
            }
            bfe += a;
        }
        // 第一年：(每一行的销售费用*销售费用比例的合计)/10000/0.9+一次性销售费用金额/10000/0.9
        if (m == 1) {
            bfn = bfn / 10000 / 0.9 + (coopDealer == '' ? otsa / 10000 / 0.9 : 0);
            bfe = bfe / 10000 / 0.9 + (coopDealer == '' ? otsa / 10000 / 0.9 : 0);
        }
        // 之后每年：每一行的销售费用*销售费用比例的合计/10000
        else {
            bfn = bfn / 10000 / 0.9;
            bfe = bfe / 10000 / 0.9;
        }
        document.getElementById('busiFee_' + m + '_dealerCalcNow').value = parseNum(bfn);
        document.getElementById('busiFee_' + m + '_dealerCalcEsti').value = parseNum(bfe);
        bfna += parseFloatExtension(bfn);
        bfea += parseFloatExtension(bfe);
        // 所得税=(毛利-费用-维修成本-业务费-仪器成本合计/1.13/年数)*0.25
        var itn = (rn - parseFloatExtension(fn) - parseFloatExtension(rcn) - parseFloatExtension(document.getElementById('busiFee_' + m + '_dealerCalcNow').value) - parseFloatExtension(document.getElementById('instCostAllNow').value / 1.13 / yearCnt)) * 0.25;
        var ite = (re - parseFloatExtension(fe) - parseFloatExtension(rce) - parseFloatExtension(document.getElementById('busiFee_' + m + '_dealerCalcEsti').value) - parseFloatExtension(document.getElementById('instCostAllEsti').value / 1.13 / yearCnt)) * 0.25;
        document.getElementById('incomeTax_' + m + '_dealerCalcNow').value = parseNum(itn);
        document.getElementById('incomeTax_' + m + '_dealerCalcEsti').value = parseNum(ite);
        itna += parseFloatExtension(itn);
        itea += parseFloatExtension(ite);
        // 试剂纯利=毛利-费用-所得税
        var rin = rn - fn - itn;
        var rie = re - fe - ite;
        document.getElementById('reagentIncome_' + m + '_dealerCalcNow').value = parseNum(rin);
        document.getElementById('reagentIncome_' + m + '_dealerCalcEsti').value = parseNum(rie);
        rina += parseFloatExtension(rin);
        riea += parseFloatExtension(rie);
        // 当年利润=试剂纯利-仪器成本/1.13-业务费-维修成本
        var yin = parseFloatExtension(rin) - parseFloatExtension(document.getElementById('dppn' + m).value) / 1.13- parseFloatExtension(bfn) - parseFloatExtension(rcn);
        var yie = parseFloatExtension(rie) - parseFloatExtension(document.getElementById('dppe' + m).value) / 1.13 - parseFloatExtension(bfe) - parseFloatExtension(rce);
        document.getElementById('yearIncome_' + m + '_dealerCalcNow').value = parseNum(yin);
        document.getElementById('yearIncome_' + m + '_dealerCalcEsti').value = parseNum(yie);
        yina += yin;
        yiea += yie;
        // 本单每年利润=当年利润+仪器成本
        var tyin = yin + parseFloatExtension(document.getElementById('dppn' + m).value);
        var tyie = yie + parseFloatExtension(document.getElementById('dppe' + m).value);
        document.getElementById('yearIncome_' + m + '_dealerYieldNow_Show').value = parseNum(tyin);
        document.getElementById('yearIncome_' + m + '_dealerYieldEsti_Show').value = parseNum(tyie);
        document.getElementById('yearIncome_' + m + '_dealerYieldNow').value = tyin;
        document.getElementById('yearIncome_' + m + '_dealerYieldEsti').value = tyie;
        tyina += parseFloatExtension(tyin);
        tyiea += parseFloatExtension(tyie);
        // 折现值=本单每年利润*折现率
        var lvn = tyin * parseFloatExtension(document.getElementById('page:form:dealerYieldNow:' + (m - 1) + ':liquidityP_first_dealerYieldNow').innerText)/ 100;
        var lve = tyie * parseFloatExtension(document.getElementById('page:form:dealerYieldEsti:' + (m - 1) + ':liquidityP_first_dealerYieldEsti').innerText)/ 100;
        document.getElementById('liquidityV_' + m + '_dealerYieldNow').value = parseNum(lvn);
        document.getElementById('liquidityV_' + m + '_dealerYieldEsti').value = parseNum(lve);
        lvna += parseFloatExtension(lvn);
        lvea += parseFloatExtension(lve);
        // 投入=仪器成本*Math.pow(1.2, -(year - 1))
        var din = parseFloatExtension(document.getElementById('dppn' + m).value) * Math.pow(1 + dealerFirstInput, (- m + 1));
        var die = parseFloatExtension(document.getElementById('dppe' + m).value) * Math.pow(1 + dealerFirstInput, (- m + 1));
        dfin += din;
        dfie += die;
    }
    // 合计值的设定

    // 试剂销售
    document.getElementById('reagentSale_all_dealerCalcNow').value = parseNum(stna);
    document.getElementById('reagentSale_all_dealerCalcEsti').value = parseNum(stea);

    //销售额 保存到对象
     var companySalesNowHidden = document.getElementById('page:form:companySalesNowHidden');
     var companySalesEstiHidden = document.getElementById('page:form:companySalesEstiHidden');
    if(companySalesNowHidden != null )companySalesNowHidden.value = stna * 10000;
    if(companySalesEstiHidden != null )companySalesEstiHidden.value = stea * 10000;
     var companySalesNowHiddenJL = document.getElementById('page:form:companySalesNowHiddenJL');
     var companySalesEstiHiddenJL = document.getElementById('page:form:companySalesEstiHiddenJL');
    if(companySalesNowHiddenJL != null )companySalesNowHiddenJL.value = stna * 10000;
    if(companySalesEstiHiddenJL != null )companySalesEstiHiddenJL.value = stea * 10000;
    // 试剂成本
    document.getElementById('reagentCost_all_dealerCalcNow').value = parseNum(ctna);
    document.getElementById('reagentCost_all_dealerCalcEsti').value = parseNum(ctea);
    // 毛利
    document.getElementById('rawIncome_all_dealerCalcNow').value = parseNum(rna);
    document.getElementById('rawIncome_all_dealerCalcEsti').value = parseNum(rea);
    // 增值税
    document.getElementById('tax_all_dealerCalcNow').value = parseNum(taxna);
    document.getElementById('tax_all_dealerCalcEsti').value = parseNum(taxea);
    // 费用
    document.getElementById('fee_all_dealerCalcNow').value = parseNum(fna);
    document.getElementById('fee_all_dealerCalcEsti').value = parseNum(fea);
    // 维修成本
    document.getElementById('repairCost_all_dealerCalcNow').value = parseNum(rcna);
    document.getElementById('repairCost_all_dealerCalcEsti').value = parseNum(rcea);
    // 业务费
    document.getElementById('busiFee_all_dealerCalcNow').value = parseNum(bfna);
    document.getElementById('busiFee_all_dealerCalcEsti').value = parseNum(bfea);
    // 所得税
    document.getElementById('incomeTax_all_dealerCalcNow').value = parseNum(itna);
    document.getElementById('incomeTax_all_dealerCalcEsti').value = parseNum(itea);
    // 试剂纯利
    document.getElementById('reagentIncome_all_dealerCalcNow').value = parseNum(rina);
    document.getElementById('reagentIncome_all_dealerCalcEsti').value = parseNum(riea);
    // 当年利润
    document.getElementById('yearIncome_all_dealerCalcNow').value = yina;
    document.getElementById('yearIncome_all_dealerCalcEsti').value = yiea;


    var companyIncomeNowHidden = document.getElementById('page:form:companyIncomeNowHidden');
    var companyIncomeEstiHidden = document.getElementById('page:form:companyIncomeEstiHidden');
    if(companyIncomeNowHidden != null )companyIncomeNowHidden.value = yina * 10000;
    if(companyIncomeEstiHidden != null )companyIncomeEstiHidden.value = yiea * 10000;
    //经理价格
     var companyIncomeNowHiddenJL = document.getElementById('page:form:companyIncomeNowHiddenJL');
    var companyIncomeEstiHiddenJL = document.getElementById('page:form:companyIncomeEstiHiddenJL');
    if(companyIncomeNowHiddenJL != null )companyIncomeNowHiddenJL.value = yina * 10000;
    if(companyIncomeEstiHiddenJL != null )companyIncomeEstiHiddenJL.value = yiea * 10000;

    document.getElementById('yearIncome_all_dealerCalcNow_Show').value = parseNum(yina);
    document.getElementById('yearIncome_all_dealerCalcEsti_Show').value = parseNum(yiea);
    // 本单每年利润:初始投入
    document.getElementById('yearIncome_first_dealerYieldNow_Show').value = -parseNum(dfin);
    document.getElementById('yearIncome_first_dealerYieldEsti_Show').value = -parseNum(dfie);
    document.getElementById('yearIncome_first_dealerYieldNow').value = -dfin;
    document.getElementById('yearIncome_first_dealerYieldEsti').value = -dfie;
    // 本单每年利润:合计
    document.getElementById('yearIncome_all_dealerYieldNow_Show').value = parseNum(-dfin + tyina);
    document.getElementById('yearIncome_all_dealerYieldEsti_Show').value = parseNum(-dfie + tyiea);
    document.getElementById('yearIncome_all_dealerYieldNow').value = -dfin + tyina;
    document.getElementById('yearIncome_all_dealerYieldEsti').value = -dfie + tyiea;
    // 折现值:初始投入
    document.getElementById('liquidityV_first_dealerYieldNow').value = -parseNum(dfin);
    document.getElementById('liquidityV_first_dealerYieldEsti').value = -parseNum(dfie);
    // 折现值:合计
    document.getElementById('liquidityV_sum_dealerYieldNow').value = lvna;
    document.getElementById('liquidityV_sum_dealerYieldEsti').value = lvea;
    document.getElementById('liquidityV_all_dealerYieldNow').value = parseNum(-dfin + lvna);
    document.getElementById('liquidityV_all_dealerYieldEsti').value = parseNum(-dfie + lvea);
    // 每年最低要求利润:初始投入
    document.getElementById('bottomIncome_first_dealerYieldNow').value = -parseNum(dfin);
    document.getElementById('bottomIncome_first_dealerYieldEsti').value = -parseNum(dfie);
    
    calculateDealer2();
    calculateDealer3();
    calculateDealer4();
}

// function copyInstCost(oid, nid) {
//     document.getElementById(nid).value = document.getElementById(oid).value;
//     document.getElementById("instCostAllNow").value = document.getElementById(oid).value;
//     document.getElementById("instCostAllEsti").value = document.getElementById(oid).value;
// }

function adjustInstCost(s, oldVal) {
    var total = 0;
    for (var i = 0; i < s; i++) {
        var val = parseNum(document.getElementById('page:form:addSer:' + i + ':cost').value, 2);
        total += val;
    }
    var oldvalue = parseFloatExtension(document.getElementById('instrumentCostSum_show').value);
   // console.log(s + '  ' + oldvalue + '  '+  total);
    document.getElementById("dppnShow").value =(oldvalue + total) / 10000.0;
    document.getElementById("dppeShow").value = (oldvalue + total) / 10000.0;
    document.getElementById("dppn1").value = (oldvalue + total) / 10000.0;
    document.getElementById("dppe1").value = (oldvalue + total) / 10000.0;
    document.getElementById("instCostAllNow").value = (oldvalue + total) / 10000.0;;
    document.getElementById("instCostAllEsti").value = (oldvalue + total) / 10000.0;;
}

function specialCost(val) {
    if (val == 0 || val == null) return 0;
    return val * 0.55; 
}
